package com.jsyh.maidu.presenter;

import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.ExceptionHelper;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.Suppidmsg;
import com.jsyh.maidu.utils.Utils;
import com.jsyh.maidu.views.SQPaySuppidView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/6/8.
 * 扫码获取信息接口
 */

public class SQPaySuppidPresenter  extends BasePresenter{
    private SQPaySuppidView sqpayview;

    public SQPaySuppidPresenter(SQPaySuppidView sqpayview){
        this.sqpayview=sqpayview;
    }
    public void setSqSuppid(final Context context,String suppid)
    {
        initLoadDialog(context);
        mLoadingDialog.show();
        Map<String,String> params=new HashMap<>();
        params.put("sid",suppid);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "scan/scanCode", params, new BaseDelegate.ResultCallback<Suppidmsg>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                mLoadingDialog.dismiss();
                Utils.showToast(context, ExceptionHelper.getMessage(e, context));
            }



            @Override
            public void onResponse(Suppidmsg response, Object tag) {
                mLoadingDialog.dismiss();
                sqpayview.getSuppidMessage(response);

            }
        },true);

    }




}
